//
//  CABtcVout.m
//  Test
//
//  Created by xgc on 12/26/17.
//  Copyright © 2017 xgc. All rights reserved.
//

#import "CABtcVout.h"

@implementation CABtcVout

+(id)initWithBtcVout: (BtcvoutForm*)vout
{
    CABtcVout* btcVout = [[CABtcVout alloc]init];
    
    string hash = vout->getHash();
    btcVout.txHash = [NSString stringWithCString:hash.c_str() encoding:[NSString defaultCStringEncoding]];
    
    btcVout.value = vout->getValue();
    btcVout.n = vout->getN();
    btcVout.coinBase = vout->getCoinBase() ? YES : NO;
    
    return btcVout;
}

-(BtcvoutForm*) toBtcvoutForm {
    
    BtcvoutForm* btcVout = new BtcvoutForm();
    btcVout->setHash([self.txHash UTF8String]);
    btcVout->setValue(self.value);
    btcVout->setN(self.n);
    btcVout->setCoinBase(self.coinBase == YES ? true : false);
    
    return btcVout;
}

-(id)init {
    if (self = [super init]) {
        
    }
    return self;
}

@end
